#! /bin/sh

# execute this script from the top-level directory
HOSTNAME=power5
DIRNAME=$HOSTNAME

CC=gcc
F77=g77
CXX=g++
CFLAGS="-O3 -fomit-frame-pointer -fstrict-aliasing -mcpu=power5"
CXXFLAGS="-O3 -fomit-frame-pointer -fstrict-aliasing -mcpu=power5"
FFLAGS="-O3 -fomit-frame-pointer -fstrict-aliasing -mcpu=power5"
FFTW_DIR=$HOME/local/power5
OPT=$HOME/local/opt

CPPFLAGS="-I$FFTW_DIR/include" 
LDFLAGS="-L$FFTW_DIR/lib"

MAKE=make

OMP_NUM_THREADS=1

FLIBS="$OPT/ibmcmp/lib/libxlfmath.so.1 $OPT/ibmcmp/lib/libxlomp_ser.so.1 $OPT/ibmcmp/lib/libxlf90_t.so.1 $OPT/ibmcmp/xlf/9.1/lib/libxl.a -lm"

export CC CXX F77 F90 LDFLAGS CFLAGS FFLAGS CPPFLAGS CXXFLAGS MAKE OMP_NUM_THREADS FLIBS

export LD_LIBRARY_PATH=$OPT/ibmcmp/lib:$FFTW_DIR/lib

if test "$NORUN"xxx = xxx; then
    rm -rf $DIRNAME
    mkdir $DIRNAME


    ( 
	cd $DIRNAME
	../configure --disable-single --with-f90
	make -k; make -k benchmark; make clean
	../configure --enable-single --with-f90
	make -k; make -k benchmark; make clean
	../configure --disable-single --with-f90
	make -k; nice -20 make -k accuracy; make clean
	../configure --enable-single --with-f90
	make -k; nice -20 make -k accuracy; make clean
	make collect OUTFILE=$DIRNAME
    )
fi
